package com.jiazhong.basic.shuxin.design.代理模式.动态代理模式;

import java.lang.reflect.Proxy;

public class App {

    private static void a() {
        ClassLoader loader = EmpMapper.class.getClassLoader();
        Class[] classes = {EmpMapper.class};
        DynamicProxyHandler dynamicProxyHandler = new DynamicProxyHandler();
        EmpMapper mapper = (EmpMapper) Proxy.newProxyInstance(loader, classes, dynamicProxyHandler);

        // mapper.save(1, "张三", 23);
        String username = mapper.findUsernameById(1);
        System.out.println("姓名：" + username);
    }


    private static void b() {
        Treat treat = new Boss();
        CGLibProxyHandler cgLibProxyHandler = new CGLibProxyHandler();
        cgLibProxyHandler.setTarget(treat);
        treat.eat();
    }

    public static void main(String[] args) {
        b();
    }
}
